﻿using Nx.Azure.Extensions;
using System;
using System.Diagnostics;
using System.Threading;

namespace Nx.Azure.Web
{
    public class TestWorker : WorkerEntryPoint
    {
        public override void Run()
        {
            Trace.TraceInformation("TestWorker:Run begin", "Information");

            try
            {
                while (true)
                {
                    // CHANGE SLEEP TIME
                    Thread.Sleep(this.Seconds30);

                    //// ADD CODE HERE

                    string traceInformation = DateTime.UtcNow.ToString() + " TestWorker:Run loop thread=" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString();
                    Trace.TraceInformation(traceInformation, "Information");
                }
            }
            catch (SystemException se)
            {
                Trace.TraceError("TestWorker:Run SystemException", se.ToString());
                throw se;
            }
            catch (Exception ex)
            {
                Trace.TraceError("TestWorker:Run Exception", ex.ToString());
            }

            Trace.TraceInformation("TestWorker:Run end", "Information");
        }
    }
}